//
//  ContactManager.m
//  OC_04字典
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ContactManager.h"

@implementation ContactManager

- (instancetype)initWithDictionary:(NSMutableDictionary *)dictionary{
      self = [super init];
      if (self) {
            _contactDictionary = dictionary;
      }
      return self;
}
- (void)addContact:(Contact *)contact{
      if (contact.name.length > 0 && contact.phoneNumber.length > 0) {
            NSMutableArray *contactArr = [_contactDictionary objectForKey:contact.groupName];
            if (contactArr == nil) {
                  contactArr = [NSMutableArray arrayWithObject:contact];
                  [_contactDictionary setObject:contactArr forKey:contact.groupName];
            }else{
                  [contactArr addObject:contact];
            
            }
            NSLog(@"添加联系人%@成功", contact.name);
            
      }else{
            NSLog(@"添加联系人%@失败", contact.name);
      
      }
      
}
- (void)removeContact:(Contact *)contact{
      
      
}
- (void)removeGroupWithGroupName:(NSString *)groupName{
      [_contactDictionary removeObjectForKey:groupName];

}


@end
